import {api} from './utils/api';
import getUrl from './utils/getUrl'
// app.js
App({
  onLaunch() {
    this.api = api;
    this.getUrl = getUrl;
    this.app_id = this.globalData.app_id;
    wx.login({
      success:(res)=>{
        const data = {
          code:res.code,
          app_id:this.app_id
        }
        console.log(res.code)

        this.api.post(this.getUrl('login'), data).then((res)=>{
          console.log(res)
          wx.setStorageSync('accessToken', res.data.access_token)
          wx.setStorageSync('user', res.data.wechat_user)
        })
      }
    })
  },
  globalData: {
    userInfo: null,
    app_id:'wx51c4f973a4e03465'

  }
})
